<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;

class UserLogin extends Base
{
    //
    public function index()
    {
        $title = '每日用户登录';

        $redis = new \Redis();
        $redis->connect('127.0.0.1','6379');

        // 用户登录数
        $count = $redis->sCard(date('m-d').'action_num');

        // 取出当前前十位用户
        $first_login_list = $redis->lRange('tpshop_first_login',0,9);
        // 将至转换成标准的数组格式
        $first_login_list = (new \think\Collection($first_login_list))->toArray();

        if(!empty($first_login_list))
        {
            $imp = implode(',',$first_login_list);
            $data = \app\admin\model\User::where('phone','in',$imp)->select();

        }else{
            $data = [];
        }

        return view('/userlogin/index',[
            'title' => $title,
            'count' => $count,
            'data' => $data
        ]);
    }


}
